import request from '@/utils/request'
import type { 
  ApiResponse,
  SystemStats,
  Setting,
  VisitRecord,
  SearchRecord
} from '@/types'

// 统计相关API
export const statisticsApi = {
  // 获取系统统计概览
  getOverview: (): Promise<ApiResponse<SystemStats>> => {
    return request.get('/statistics/overview')
  },

  // 获取系统配置
  getSettings: (): Promise<ApiResponse<Setting[]>> => {
    return request.get('/statistics/settings')
  },

  // 更新系统配置
  updateSettings: (data: Partial<Setting>): Promise<ApiResponse<string>> => {
    return request.put('/statistics/settings', data)
  },

  // 获取访问统计数据
  getVisits: (): Promise<ApiResponse<VisitRecord[]>> => {
    return request.get('/statistics/visit')
  },

  // 获取热门关键词
  getHotKeywords: (): Promise<ApiResponse<SearchRecord[]>> => {
    return request.get('/statistics/search/hot')
  },

  // 获取搜索记录（管理员权限）
  getSearchRecords: (): Promise<ApiResponse<SearchRecord[]>> => {
    return request.get('/statistics/search/records')
  }
}